using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1 {
    public partial class Form1 : Form {

        private User user;
                
        public Form1() {
            InitializeComponent();
            user = new User();
            User.OnValidationErrors = HandleValidationErrors;
            tbUserName.DataBindings.Add("Text", user, "UserName");
            tbPassword.DataBindings.Add("Text", user, "Password");
        }

        private void HandleValidationErrors(StringBuilder errors)
        {
            MessageBox.Show(errors.ToString());
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show(user.UserName);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show(user.Password);
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            user.Save();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            user.UserName = "Bob";
        }



        

    }
}